#include <stdlib.h>
#include "framework.h"
#include "log/log.h"

/*
 * main entrance.  
 */
int main(int argc, char* argv[]) {
	int gExecuteCount = 1024;
	try {
		CFrameWork framework;
		const char* path = nullptr;

		// ./run path
		if (argc >= 2) {
			path = argv[1];
		} else {
			path = "./bin/Debug";
		}

		// ./run path count where count is run count.
		if (argc >= 3) {
			gExecuteCount = std::atoi(argv[2]);
		}

		// Try to create all instances.
		framework.CreateInstances();

		if (framework.Init(path)) {
			framework.Run(gExecuteCount);
		}
		// release the program after exit.
		framework.Release();
		return 0;
	} catch (const std::exception& e) {
		LogCrit("Error: %s", e.what());
		return -1;
	} catch (...) {
		LogCrit("Unknown error occurred");
		return -1;
	}
}
